# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python

class Recipe(recipe.Recipe):
    name = 'ninja'
    version = '1.9.0'
    licenses = [License.Apachev2]
    btype = BuildType.CUSTOM
    stype = SourceType.TARBALL
    url = 'https://github.com/ninja-build/ninja/archive/v%(version)s.tar.gz'
    tarball_checksum = '5d7ec75828f8d3fd1a0c2f31b5b0cea780cdfe1031359228c428c1a48bfcd5b9'
    patches = ['ninja/0001-configure.py-Look-for-cl.exe-before-assuming-MSVC.patch']
    deps = []

    files_bin = ['bin/ninja']

    def configure(self):
        shell.new_call([self.config.python_exe, 'configure.py', '--bootstrap'],
                       self.build_dir, logfile=self.logfile, env=self.env)

    def install(self):
        ninja = 'ninja'
        if self.platform == Platform.WINDOWS:
            ninja += '.exe'
        os.replace(os.path.join(self.build_dir, ninja),
                   os.path.join (self.config.prefix, "bin", ninja))
